package com.yc.spi;

import java.util.Iterator;
import java.util.ServiceLoader;

import sun.misc.Service;

public class Test {

	public static void main(String[] args) {
		System.out.println("-----------使用sun.misc.Service---------------");
		Iterator<SPIService> providers = Service.providers(SPIService.class);
		while(providers.hasNext()) {
			SPIService ser = providers.next();
			ser.execute();
		}
		
		System.out.println("----------使用java.util.ServiceLoader----------------");
		ServiceLoader<SPIService> load = ServiceLoader.load(SPIService.class);
		Iterator<SPIService> iterator = load.iterator();
		while(iterator.hasNext()) {
			SPIService ser = iterator.next();
			ser.execute();
		}
	}

}
